package com.lyhdev.android.touchenglish;

import java.util.ArrayList;

public class TEChannel {
	
	private ArrayList<TEQuiz> quizList = new ArrayList<TEQuiz>();

	public void addQuiz(TEQuiz quiz) {
		quizList.add(quiz);
	}
	
	public int getQuizSize() {
		return quizList.size();
	}
	
	public TEQuiz getQuiz(int index) {
		return quizList.get(index);
	}
	
	public void cacheAllImage() {
		//cache first
		if (quizList.size() > 0) {
			quizList.get(0).cacheImage();
		}

		if (quizList.size() > 1) {
			Runnable r = new Runnable() {
				public void run() {
					try {
						for (int i = 1; i < quizList.size(); i++) {
							quizList.get(i).cacheImage();
						}
					} catch (Exception ex) {
						ex.printStackTrace();
					}
				}
			};
			new Thread(r).start();
		}
	}
}
